package com.origon.entities;

import java.io.Serializable;
import javax.persistence.*;
import java.sql.Timestamp;
import java.util.List;
import java.util.UUID;


/**
 * The persistent class for the mail database table.
 * 
 */
@Entity
public class Mail implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	private String id;

	private String body;

	private Timestamp date;

	private String recipient;

	private Boolean senderExists;

	private String subject;

	//bi-directional many-to-one association to Inbox
	@OneToMany(mappedBy="mail")
	private List<Inbox> inboxs;

	//bi-directional many-to-one association to User
	@ManyToOne
	@JoinColumn(name="SenderId")
	private User user;

	//bi-directional many-to-many association to User
	@ManyToMany(mappedBy="mails2")
	private List<User> users;

	public Mail() {
		setId(UUID.randomUUID().toString());
	}

	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getBody() {
		return this.body;
	}

	public void setBody(String body) {
		this.body = body;
	}

	public Timestamp getDate() {
		return this.date;
	}

	public void setDate(Timestamp date) {
		this.date = date;
	}

	public String getRecipient() {
		return this.recipient;
	}

	public void setRecipient(String recipient) {
		this.recipient = recipient;
	}

	public Boolean getSenderExists() {
		return this.senderExists;
	}

	public void setSenderExists(Boolean senderExists) {
		this.senderExists = senderExists;
	}

	public String getSubject() {
		return this.subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public List<Inbox> getInboxs() {
		return this.inboxs;
	}

	public void setInboxs(List<Inbox> inboxs) {
		this.inboxs = inboxs;
	}

	public Inbox addInbox(Inbox inbox) {
		getInboxs().add(inbox);
		inbox.setMail(this);

		return inbox;
	}

	public Inbox removeInbox(Inbox inbox) {
		getInboxs().remove(inbox);
		inbox.setMail(null);

		return inbox;
	}

	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public List<User> getUsers() {
		return this.users;
	}

	public void setUsers(List<User> users) {
		this.users = users;
	}

}